package com.googlecode.chigs.web;

import brix.Brix;
import brix.Plugin;
import brix.auth.AuthorizationStrategy;
import brix.config.BrixConfig;
import brix.plugin.menu.MenuPlugin;
import brix.plugin.prototype.PrototypePlugin;
import brix.plugin.site.page.tile.Tile;
import brix.plugin.snapshot.SnapshotPlugin;
import brix.plugin.webdavurl.WebdavUrlPlugin;

import com.googlecode.chigs.web.admin.AdminStatisticsTile;
import com.googlecode.chigs.web.admin.configlocation.ManageLocationsTile;
import com.googlecode.chigs.web.admin.configlocationgroup.ManageLocationGroupsTile;
import com.googlecode.chigs.web.admin.product.ManageProductsTile;
import com.googlecode.chigs.web.admin.user.ManageUserTile;
import com.googlecode.chigs.web.admin.variant.ManageVariantsTile;
import com.googlecode.chigs.web.admin.version.ManageVersionsTile;
import com.googlecode.chigs.web.auth.LoginTile;
import com.googlecode.chigs.web.config.configrevision.ManageConfigRevisionsTile;
import com.googlecode.chigs.web.config.configuration.ManageConfigurationsTile;
import com.googlecode.chigs.web.doku.module.ManageModulesTile;
import com.googlecode.chigs.web.doku.revision.ManageRevisionsTile;

/**
 * Subclass of {@link Brix} that configures demo-specific settings such as plugins, tiles, etc.
 * 
 * @author igor.vaynberg
 * 
 */
public class ChigsBrix extends Brix {
    /**
     * Constructor
     * 
     * @param config
     */
    public ChigsBrix(BrixConfig config) {
        super(config);

        // register plugins
        config.getRegistry().register(Plugin.POINT, new MenuPlugin(this));
        config.getRegistry().register(Plugin.POINT, new SnapshotPlugin(this));
        config.getRegistry().register(Plugin.POINT, new PrototypePlugin(this));
        config.getRegistry().register(Plugin.POINT, new WebdavUrlPlugin());

        // Login & User stuff
        config.getRegistry().register(Tile.POINT, new LoginTile());
        config.getRegistry().register(Tile.POINT, new UserTile());
        config.getRegistry().register(Tile.POINT, new SettingsTile());
        config.getRegistry().register(Tile.POINT, new SignupTile());

        // Admin
        config.getRegistry().register(Tile.POINT, new ManageLocationsTile());
        config.getRegistry().register(Tile.POINT, new ManageLocationGroupsTile());
        config.getRegistry().register(Tile.POINT, new AdminStatisticsTile());
        config.getRegistry().register(Tile.POINT, new ManageProductsTile());
        config.getRegistry().register(Tile.POINT, new ManageUserTile());
        config.getRegistry().register(Tile.POINT, new ManageVariantsTile());
        config.getRegistry().register(Tile.POINT, new ManageVersionsTile());
        
        // Feedback
        config.getRegistry().register(Tile.POINT, new FeedbackTile());

        // Statistics
        config.getRegistry().register(Tile.POINT, new StatisticsTile());
        
        // Documentation
        config.getRegistry().register(Tile.POINT, new ManageModulesTile());
        config.getRegistry().register(Tile.POINT, new ManageRevisionsTile());
        
        // Configuration
        config.getRegistry().register(Tile.POINT, new ManageConfigurationsTile());
        config.getRegistry().register(Tile.POINT, new ManageConfigRevisionsTile());
    }

    /** {@inheritDoc} */
    @Override
    public AuthorizationStrategy newAuthorizationStrategy() {
        // register our simple demo auth strategy
        return new ChigsAuthorizationStrategy();
    }
}
